﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ClientMapping.cs" company="Concept Architecture">
//   (c) 2010 Muhammad Umer Farooq
// </copyright>
// <summary>
//   Defines the ClientMapping type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Hisaab.Windows.Client
{
    using System.Diagnostics;
    using AutoMapper;
    using Model;

    /// <summary>
    /// Defines the <seealso cref="Hisaab.Windows.Client.ClientMapping"/> type.
    /// </summary>
    public class ClientMapping : Profile
    {
        /// <summary>
        /// Configures this instance.
        /// </summary>
        [DebuggerStepThrough]
        protected override void Configure()
        {
            CreateMap<Business.Entities.Account, Account>()
                .ForMember(s => s.AccountId, o => o.MapFrom(d => d.AccountId))
                .ForMember(s => s.AccountType, o => o.MapFrom(d => d.AccountType))
                .ForMember(s => s.Name, o => o.MapFrom(d => d.Name));

            CreateMap<Account, Business.Entities.Account>()
                .ForMember(s => s.AccountId, o => o.MapFrom(d => d.AccountId))
                .ForMember(s => s.AccountType, o => o.MapFrom(d => d.AccountType))
                .ForMember(s => s.Name, o => o.MapFrom(d => d.Name));

            CreateMap<Business.Entities.AccountSummary, AccountSummary>()
                .ForMember(s => s.EndingBalance, o => o.MapFrom(d => d.EndingBalance))
                .ForMember(s => s.TransactionCount, o => o.MapFrom(d => d.TransactionCount))
                .ForMember(s => s.ChartData, o => o.MapFrom(d => d.ChartData));

            CreateMap<AccountSummary, Business.Entities.AccountSummary>()
                .ForMember(s => s.EndingBalance, o => o.MapFrom(d => d.EndingBalance))
                .ForMember(s => s.TransactionCount, o => o.MapFrom(d => d.TransactionCount))
                .ForMember(s => s.ChartData, o => o.MapFrom(d => d.ChartData));

            CreateMap<Business.Entities.AccountType, AccountType>()
                .ForMember(s => s.Id, o => o.MapFrom(d => d.Id))
                .ForMember(s => s.Name, o => o.MapFrom(d => d.Name));

            CreateMap<AccountType, Business.Entities.AccountType>()
                .ForMember(s => s.Id, o => o.MapFrom(d => d.Id))
                .ForMember(s => s.Name, o => o.MapFrom(d => d.Name));

            CreateMap<Business.Entities.Tag, Tag>()
                .ForMember(s => s.TagId, o => o.MapFrom(d => d.TagId))
                .ForMember(s => s.Name, o => o.MapFrom(d => d.Name));

            CreateMap<Tag, Business.Entities.Tag>()
                .ForMember(s => s.TagId, o => o.MapFrom(d => d.TagId))
                .ForMember(s => s.Name, o => o.MapFrom(d => d.Name));

            CreateMap<Business.Entities.Transaction, Transaction>()
                .ForMember(s => s.TransactionId, o => o.MapFrom(d => d.TransactionId))
                .ForMember(s => s.Title, o => o.MapFrom(d => d.Title))
                .ForMember(s => s.Details, o => o.MapFrom(d => d.Details))
                .ForMember(s => s.Amount, o => o.MapFrom(d => d.Amount))
                .ForMember(s => s.Account, o => o.MapFrom(d => d.Account))
                .ForMember(s => s.Date, o => o.MapFrom(d => d.Date))
                .ForMember(s => s.Tags, o => o.MapFrom(d => d.Tags))
                .ForMember(s => s.LinkedTransactionAccount, o => o.MapFrom(d => d.LinkedTransactionAccount))
                .ForMember(s => s.LinkedTransactionDate, o => o.MapFrom(d => d.LinkedTransactionDate))
                .ForMember(s => s.IsTransferTransaction, o => o.Ignore())
                .ForMember(s => s.RelatedTransactionId, o => o.MapFrom(d => d.RelatedTransactionId))
                .ForMember(s => s.TransactionType, o => o.MapFrom(d => d.TransactionType));

            CreateMap<Transaction, Business.Entities.Transaction>()
                .ForMember(s => s.TransactionId, o => o.MapFrom(d => d.TransactionId))
                .ForMember(s => s.Title, o => o.MapFrom(d => d.Title))
                .ForMember(s => s.Details, o => o.MapFrom(d => d.Details))
                .ForMember(s => s.Amount, o => o.MapFrom(d => d.Amount))
                .ForMember(s => s.Account, o => o.MapFrom(d => d.Account))
                .ForMember(s => s.Date, o => o.MapFrom(d => d.Date))
                .ForMember(s => s.Tags, o => o.MapFrom(d => d.Tags))
                .ForMember(s => s.LinkedTransactionAccount, o => o.MapFrom(d => d.LinkedTransactionAccount))
                .ForMember(s => s.LinkedTransactionDate, o => o.MapFrom(d => d.LinkedTransactionDate))
                .ForMember(s => s.RelatedTransactionId, o => o.MapFrom(d => d.RelatedTransactionId))
                .ForMember(s => s.TransactionType, o => o.MapFrom(d => d.TransactionType));

            CreateMap<Business.Entities.Vehicle, Vehicle>()
                .ForMember(s => s.Id, o => o.MapFrom(d => d.Id))
                .ForMember(s => s.Name, o => o.MapFrom(d => d.Name))
                .ForMember(s => s.UserId, o => o.MapFrom(d => d.UserId));

            CreateMap<Vehicle, Business.Entities.Vehicle>()
                .ForMember(s => s.Id, o => o.MapFrom(d => d.Id))
                .ForMember(s => s.Name, o => o.MapFrom(d => d.Name))
                .ForMember(s => s.UserId, o => o.MapFrom(d => d.UserId));

            CreateMap<Business.Entities.VehicleTransaction, VehicleTransaction>()
                .ForMember(s => s.Id, o => o.MapFrom(d => d.Id))
                .ForMember(s => s.TransactionId, o => o.MapFrom(d => d.TransactionId))
                .ForMember(s => s.Milage, o => o.MapFrom(d => d.Milage))
                .ForMember(s => s.Fill, o => o.MapFrom(d => d.Fill))
                .ForMember(s => s.Oil, o => o.MapFrom(d => d.Oil))
                .ForMember(s => s.Fuel, o => o.MapFrom(d => d.Fuel))
                .ForMember(s => s.Service, o => o.MapFrom(d => d.Service))
                .ForMember(s => s.VehicleId, o => o.MapFrom(d => d.VehicleId));

            CreateMap<VehicleTransaction, Business.Entities.VehicleTransaction>()
                .ForMember(s => s.Id, o => o.MapFrom(d => d.Id))
                .ForMember(s => s.TransactionId, o => o.MapFrom(d => d.TransactionId))
                .ForMember(s => s.Milage, o => o.MapFrom(d => d.Milage))
                .ForMember(s => s.Fill, o => o.MapFrom(d => d.Fill))
                .ForMember(s => s.Oil, o => o.MapFrom(d => d.Oil))
                .ForMember(s => s.Service, o => o.MapFrom(d => d.Service))
                .ForMember(s => s.VehicleId, o => o.MapFrom(d => d.VehicleId));

            CreateMap<Business.Entities.AccountMonthlyTotal, AccountMonthlyTotal>()
                .ForMember(s => s.Month, o => o.MapFrom(d => d.Month))
                .ForMember(s => s.MonthlyTotal, o => o.MapFrom(d => d.MonthlyTotal))
                .ForMember(s => s.CumulativeTotal, o => o.MapFrom(d => d.CumulativeTotal));

            CreateMap<AccountMonthlyTotal, Business.Entities.AccountMonthlyTotal>()
                .ForMember(s => s.Month, o => o.MapFrom(d => d.Month))
                .ForMember(s => s.MonthlyTotal, o => o.MapFrom(d => d.MonthlyTotal))
                .ForMember(s => s.CumulativeTotal, o => o.MapFrom(d => d.CumulativeTotal));

            Mapper.AssertConfigurationIsValid();
        }
    }
}